package com.atguigu.tingshu.album.mapper;

import com.atguigu.tingshu.model.album.TrackInfo;
import com.atguigu.tingshu.query.album.TrackInfoQuery;
import com.atguigu.tingshu.vo.album.AlbumTrackListVo;
import com.atguigu.tingshu.vo.album.TrackListVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface TrackInfoMapper extends BaseMapper<TrackInfo> {



    @Select("select max(order_num) from track_info where album_id = #{albumId}")
    Integer selectMaxOrderNumByAlbumId(@Param("albumId") Long albumId);

    Page<TrackListVo> findUserTrackPage(@Param("page")  Page<TrackListVo> trackListVoPage,@Param("vo") TrackInfoQuery trackInfoQuery);

    Page<AlbumTrackListVo> findAlbumTrackPage(@Param("albumId") Long albumId, @Param("trackListVoPage") Page<AlbumTrackListVo> trackListVoPage);

    @Update("update track_stat set stat_num = stat_num + #{count} where track_id = #{trackId} and stat_type = #{statType}")
    void updateStat(@Param("trackId") Long trackId,@Param("statType") String statType,@Param("count") Integer count);
}
